package io.renren.modules.user.controller;

import java.util.*;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.modules.user.entity.*;
import io.renren.modules.user.entity.vo.PeopleApplyVo;
import io.renren.modules.user.service.TApplyRecordService;
import io.renren.modules.user.service.TPeopleCopyService;
import io.renren.modules.user.service.TPeopleService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.user.service.TApplyService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 审批表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-08-08 12:18:58
 */
@RestController
@RequestMapping("/tapply")
public class TApplyController {
    @Autowired
    private TApplyService tApplyService;
    @Autowired
    private TApplyRecordService tApplyRecordService;
    @Autowired
    private TPeopleCopyService tPeopleCopyService;
    @Autowired
    private TPeopleService tPeopleService;
    /**
     * 列表
     */
    @RequestMapping("/list")
   // @RequiresPermissions("user:tapply:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tApplyService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("user:tapply:info")
    public R info(@PathVariable("id") Integer id){
		TApplyEntity tApply = tApplyService.getById(id);

        return R.ok().put("tApply", tApply);
    }

    /**
     * 保存
     */
    @RequestMapping("/saveApply")
    @RequiresPermissions("user:tapply:save")
    public R saveApply(@RequestBody TApplyEntity tApply){
		tApplyService.saveApply(tApply);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("user:tapply:update")
    public R update(@RequestBody TApplyEntity tApply){
		tApplyService.updateById(tApply);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("user:tapply:delete")
    public R delete(@RequestBody Integer[] ids){
		tApplyService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }


    /*
     * 审批
     * */
    @RequestMapping("/updateApply")
    @RequiresPermissions("user:tapply:apply")
    public R updateApply(@RequestBody TApplyRecordEntity tApplyRecordEntity){
        R r = tApplyService.updateApply(tApplyRecordEntity);
        return r;
    }


    @RequestMapping("/listApply")
     //@RequiresPermissions("user:tapply:list")
    public R listApply(@RequestBody TApplyRecordEntity recordEntity){
        List<TApplyRecordEntity> list = tApplyRecordService.findApplyById(recordEntity);
        return R.ok().put("page", list);
    }

    /*
    * 查询临时表信息
    * */
    @RequestMapping("/peopleCopyInfo")
   // @RequiresPermissions("user:tpeople:list")
    public R peopleCopyInfo(String peopleId){
        TPeopleEntity tPeople = tPeopleCopyService.findpeople(peopleId);
      // List<String> stringsList=new ArrayList<>();
        PeopleApplyVo peopleApplyVo=new PeopleApplyVo();
        StringBuffer string=new StringBuffer();

            if(null !=tPeople.getDept()){
                string.append("修改部门为："+tPeople.getDetachment()+";");
            }
            if(null !=tPeople.getClasses()) {
                string.append("修改班组为："+tPeople.getClassesName()+";");
            }if(null !=tPeople.getName()) {
                string.append("修改名字为："+tPeople.getName()+";");
            } if(null!=tPeople.getOldName()) {
                string.append("修改曾用名为："+tPeople.getOldName()+";");
            } if(null !=tPeople.getSex()) {
                string.append("修改性别为："+tPeople.getSex()+";");

            } if(null !=tPeople.getEthnic()) {
                string.append("修改民族为："+tPeople.getMinName()+";");
            } if(null !=tPeople.getBirthday()) {
                string.append("修改生日为："+tPeople.getBirthday()+";");
            } if(null !=tPeople.getBround()) {
                string.append("修改籍贯为："+tPeople.getBround()+";");

            } if(null !=tPeople.getIdcard()) {
                string.append("修改身份证为："+tPeople.getIdcard()+";");
            } if(null !=tPeople.getWorkidcard()) {

                string.append("修改工作证为："+tPeople.getWorkidcard()+";");
            } if(null !=tPeople.getDutytime()) {

                string.append("修改入职时间为："+tPeople.getDutytime()+";");
            }
            if(tPeople.getTitle()!=null) {

                string.append("修改衔级为："+tPeople.getTitleName()+";");
            }
            if(null!=tPeople.getTitleTime()) {

                string.append("修改当前衔级时间为："+tPeople.getTitleTime()+";");
            }
            if(null!=tPeople.getDutyPost()) {

                string.append("修改专业岗位为："+tPeople.getGname()+";");
            } if(null!=tPeople.getDutyPostTime()) {

                string.append(";修改当前岗位时间为："+tPeople.getDutyPostTime()+";");
            }
            if(null!=tPeople.getFirePostClass()) {

                string.append("修改职务等级为："+tPeople.getName7()+";");
            }
            if(null!=tPeople.getFireClassTime()) {

                string.append("修改职务年月为："+tPeople.getFireClassTime()+";");
            }
            if(null !=tPeople.getTecClass()) {

                string.append(";修改技术等级为："+tPeople.getTecClass()+";");
            } if(null!=tPeople.getTecClassTime()) {

                string.append(";修改技术等级年月为："+tPeople.getTecClassTime()+";");
            } if(null!=tPeople.getAdministration()) {

                string.append("修改行政职务为："+tPeople.getXname()+";");
            } if(null!=tPeople.getAdministrationTime()) {

                string.append("修改行政职务时间为："+tPeople.getAdministrationTime()+";");
            } if(null !=tPeople.getHousehold()) {

                string.append("修改户籍为："+tPeople.getHousehold()+";");
            } if(null !=tPeople.getRegisterType()) {

                string.append("修改户口类型为："+tPeople.getRegisterType()+";");
            } if(null !=tPeople.getInvitationHousehold()) {

                string.append("修改招录前户籍为："+tPeople.getInvitationHousehold()+";");
            } if(null !=tPeople.getInvitationRegister()) {

                string.append("修改招录前户籍类型为："+tPeople.getInvitationRegister()+";");
            } if(null !=tPeople.getInvitation()) {

                string.append(";修改招录地省为："+tPeople.getInvitation()+";");
            }
            if(null !=tPeople.getPolitical()) {

                string.append(";修改政治面貌为："+tPeople.getPolitical()+";");
            } if(null !=tPeople.getPoliTime()) {

                string.append("修改入党时间为："+tPeople.getPoliTime()+";");
            } if(null !=tPeople.getEducation()) {

                string.append("修改文化程度为："+tPeople.getEducation()+";");
            } if(null !=tPeople.getSchool()) {

                string.append("修改毕业学校为："+tPeople.getSchool()+";");
            } if(null !=tPeople.getMajor()) {

                string.append("修改专业为："+tPeople.getMajor()+";");
            } if(null !=tPeople.getEducationTime()) {

                string.append("修改毕业时间为："+tPeople.getEducationTime()+";");
            } if(null !=tPeople.getSolo()) {

                string.append("修改独生子女为："+tPeople.getSolo()+";");
            } if(null !=tPeople.getCadre()) {

                string.append("修改干部子女为："+tPeople.getCadre()+";");
            } if(null !=tPeople.getHomeType()) {

                string.append("修改家庭情况为："+tPeople.getHomeType()+";");
            }
            if(null !=tPeople.getBlood()) {

                string.append("修改血型为："+tPeople.getBlood()+";");
            }
            if(null !=tPeople.getHight()) {

                string.append("修改身高为："+tPeople.getHight()+";");
            }

            if(null !=tPeople.getContractType()) {

                string.append("合同期限："+tPeople.getContractType()+";");
            } if(null !=tPeople.getSeniorityHistory() ) {

                string.append("修改入职前工龄为："+tPeople.getSeniorityHistory()+";");
            } if(null !=tPeople.getSeniorityNow()) {

                string.append("修改本单位工龄为："+tPeople.getSeniorityNow()+";");
            } if(null !=tPeople.getSeniorityTotal()) {

                string.append("修改总工龄为："+tPeople.getSeniorityTotal()+";");
            } if(null !=tPeople.getCallPhone()) {

                string.append("修改手机为："+tPeople.getCallPhone()+";");
            } if(null !=tPeople.getFileNumber()) {

                string.append("修改档案号码为："+tPeople.getFileNumber()+";");
            } if(null !=tPeople.getStrength()) {

                string.append("修改特长为："+tPeople.getStrength()+";");
            } if(null !=tPeople.getInstructions()) {

                string.append("修改说明为："+tPeople.getInstructions()+";");
            }
            if(null !=tPeople.getAccessories()) {

                string.append("修改附件为："+tPeople.getAccessories()+";");
            }
            if(null !=tPeople.getPeopleType()) {

                string.append("修改人员类型为："+tPeople.getPeopleType()+";");
            }
            if(null !=tPeople.getPeopleType()) {

                string.append("修改人员类型为："+tPeople.getPeopleType()+";");
            }
            if(null !=tPeople.getEmail()) {

            string.append("修改邮箱为："+tPeople.getEmail()+";");
            }

             peopleApplyVo.setStr(string.toString());
             peopleApplyVo.setApplyTime(tPeople.getApplyTime());
           //  peopleApplyVo.setId(id);
        return R.ok().put("stringsList", peopleApplyVo);
    }




}
